<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title><?php echo C("SITE_NAME");?>管理后台</title>
<link rel="shortcut icon" href=" /favicon.ico" />
<link rel="stylesheet" href="/Static/admin/css/component-min.css">
<link rel="stylesheet" href="/Static/admin/css/home.2015.05.22-09.32.css">
<link rel="stylesheet" href="/Static/admin/icon/iconfont.css">
<!--弹窗-->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script src="/Static/admin/js/layer-2.x/layer.js?v=1.9.0"></script>
<script src="/Static/admin/js/common.js"></script>
<script>
	var UPYUN_DOMAIN = '<?php echo C("UPYUN_DOMAIN");?>';
</script>
</head>
<body class="cp-bodybox">
<!--[if lt IE 9]>
<div class="alert alert-danger disable-del txtCenter" id="tipLowIEVer">
    <h4>系统检测到您使用的浏览器版本过低，为达到更好的体验效果请升级您的浏览器，我们为您推荐：</h4>
    <p>
        <a href="http://www.firefox.com.cn/download/" target="_blank">Firefox浏览器</a>
        <a href="http://www.maxthon.cn/" target="_blank">遨游浏览器</a>
        <a href="http://se.360.cn/" target="_blank">360浏览器</a>
    </p>
</div>
<![endif]-->
<style>
.header-nav-list a {
  display: block;
  padding: 0 10px;
  min-width: 70px;
  line-height: 53px;
  font-size: 14px;
  text-align: center;
  font-weight: 700;
}
</style>

<div class="header">
    <div class="inner clearfix">
        <div class="fl">
            <a href="/" class="header-logo">
                <img
                    src="<?php echo C('UPYUN_DOMAIN'); echo C('SITE_TOPLOGO2');?>"
                    onerror="javascript:this.src='/Static/admin/images/error.png';"
                    ></a>
        </div>
        <!-- end logo -->

        <div class="header-nav fl">
            <ul class="header-nav-list clearfix">
                <!--<li class="fl <?php echo ($controller == 'index')?'active':'';?>"><a href="/admin">首页</a></li>-->
                <?php foreach($MENU as $k=>$v){?>
                <li class="fl <?php echo ($controller == $v['controller'])?'active':'';?>">
                    <a href="<?php echo $v['url'];?>"><?php echo $v['title'];?></a>
                </li>
                <?php } ?>
            </ul>
        </div>
        <!-- end header-nav -->

        <div class="fr">
            <ul class="header-ctrl clearfix">
                <li class="header-ctrl-item fl"><a href="/admin/login/logout">退出</a></li>
            </ul>
        </div>

        <span class="account_inbox_switch fr"></span>
        <span class="header-welcome fr">
            <a href="javasecript:;" class="tips" data-trigger="hover" data-placement="top"><?php echo $admininfo['username'];?></a>
        </span>

    </div>
</div>
<!-- end header -->
	<div class="container">
		<div class="inner clearfix">
			
			<div class="content-left fl">
				<dl class="left-menu shop_8">
					<dt>
						<i class="icon-menu home"></i> <span id="shop_0" data-id="0">管理员管理</span>
					</dt>
					<dd class="<?php echo ($action == 'index')?'active':'';?>">
						<a href="/admin/manager/index">管理员列表</a>
					</dd>

					<dd class="<?php echo ($action == 'addmanager')?'active':'';?>">
						<a href="/admin/manager/addmanager">添加用户</a>
					</dd>

				</dl>
<!-- 
				<dl class="left-menu shop_8">
					<dt>
						<i class="icon-menu pencil"></i> <span id="shop_1" data-id="1">用户角色</span>
					</dt>
					<dd class="<?php echo ($action == 'rolelist')?'active':'';?>">
						<a href="/admin/manager/rolelist">角色列表</a>
					</dd>
					<dd class="<?php echo ($action == 'addrole')?'active':'';?>">
						<a href="/admin/manager/addrole">添加角色</a>
					</dd>
				</dl>
				
-->	
				<dl class="left-menu shop_8">
					<dt>
						<i class="icon-menu pencil"></i> <span id="shop_1" data-id="1">修改密码</span>
					</dt>
					<dd class="<?php echo ($action == 'changepassword')?'active':'';?>">
						<a href="/admin/manager/changepassword">修改密码</a>
					</dd>
				</dl>

			</div>
<style>
    .menus{
        padding:10px 10px;
        border:1px #ededed solid;
        margin-top:10px;
    }
    .menus label{
        padding:5px;
    }
</style>
<div class="content-right fl">

    <h1 class="content-right-title">添加/编辑管理员</h1>

    <form action="" id="form" method="POST">

        <div class="formitems">  
            <label class="fi-name"><span class="colorRed">*</span>管理员账号：</label>
            <div class="form-controls">
                <input type="text" class="input xlarge" name="username" value="<?php echo $minfo['username'];?>" <?php echo $minfo['username'] ? "readonly":"";?>>
                       <span class="fi-help-text">请输入管理员账号</span>
            </div>
        </div>

        <!--		<div class="formitems">  
                                <label class="fi-name"><span class="colorRed">*</span>管理员角色：</label>
                                <div class="form-controls">
                                        <select name="role_id" class="select  new">
                            <option value="-1">选择角色</option>
                            <?php foreach($datalist as $k=>$v){?>
                            <option value="<?php echo $v['role_id'];?>"   <?php echo ($v['role_id']==$minfo['role_id'])? "selected":"";?>><?php echo $v['role_name'];?></option>
                                                <?php } ?>
                            
                        </select>
                                        
                                        
                                        <span class="fi-help-text">管理员角色</span>
                                </div>
                        </div>-->

        <div class="formitems">
            <label class="fi-name">不可修改数据：</label>
            <div class="form-controls">
                <div class="radio-group">
                    <label><input type="radio" class="is_free_logistics" value="1" name="only_read" <?php echo isset($minfo['only_read']) && ($minfo['only_read']) ? "checked" : (!isset($minfo['only_read']) ? "checked":"");?>>不可修改</label>
                    <label><input type="radio" class="is_free_logistics" value="0" name="only_read" <?php echo isset($minfo['only_read']) && (!$minfo['only_read']) ? "checked" : "";?>>可修改</label>
                </div>
                <span class="fi-help-text"></span>
            </div>
        </div>
        
        <div id="app" class="formitems">  
            <label class="fi-name"><span class="colorRed">*</span>管理员权限：</label>
            <div class="form-controls">
                <div>
                    <template v-for="(item,index) in menus">
                        <div class="menus">
                            <div style="border-bottom: 1px #ededed solid;padding-bottom: 10px;">
                                {{item.menu.title}}：
                                <label style="display:none;"><input :value="item.menu.id" name="menu[]" type="checkbox" v-model="hasChild(index)"/>{{item.menu.title}}</label>
                                <label @click="selectAll(index)">
                                    <input type="checkbox" style="vertical-align:middle;"  v-model="item.menu.all" />
                                    <span>全选</span>
                                </label>
                            </div>
                            
                            <div v-if="pageList(index).length>0" style="padding:10px 0px;">
                                <span>页面：</span><br>
                                <template v-for="(citem,cindex) in pageList(index)">
                                    <label style='display:none;' v-if="citem.is_default==1"><input  style="vertical-align:middle;"  type="checkbox" name="submenu[]" :value="citem.id" v-model="hasChild(index)"/>{{citem.title}}</label>
                                    <label><input  style="vertical-align:middle;"  type="checkbox" name="submenu[]" :value="citem.id" v-model="citem.checked"/>{{citem.title}}</label>
                                </template>
                            </div>
                            
                            <div v-if="actionList(index).length>0" style="padding:10px 0px;">
                                <span>操作：</span><br>
                                <template v-for="(citem,cindex) in actionList(index)">
                                    <label v-if="citem.is_default==1"><input  style="vertical-align:middle;"  type="checkbox" name="submenu[]" :value="citem.id" v-model="hasChild(index)"/>{{citem.title}}</label>
                                    <label v-if="citem.is_default!=1"><input  style="vertical-align:middle;"  type="checkbox" name="submenu[]" :value="citem.id" v-model="citem.checked"/>{{citem.title}}</label>
                                </template>
                            </div>
                            
                        </div>
                    </template>
                </div>
                <span class="fi-help-text"></span>
            </div>
        </div>
        
        <div class="formitems">  
            <label class="fi-name"><span class="colorRed">*</span>管理员密码：</label>
            <div class="form-controls">
                <input type="text" class="input xlarge" name="password" value="" >
                <span class="fi-help-text">管理员密码 <?php if($minfo['username']){?>(编辑时,不填写则不更改)<?php } ?></span>
            </div>
        </div>

        <div class="formitems">  
            <label class="fi-name">管理员商城ID：</label>
            <div class="form-controls">
                <input type="text" class="input xlarge" name="uid" value="<?php echo $minfo['uid'];?>">
                <span class="fi-help-text">请填写管理员在商城的用户ID,用于手机端管理等</span>
            </div>
        </div>


        <div class="mgl120">
            <a href="javascript:AjaxFormSubmit();" class="btn btn-primary j-add">保 存</a>
        </div>
    </form>

</div>
<script src="//cdn.bootcss.com/vue/2.4.2/vue.min.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            menus: JSON.parse('<?=$menus?>'),
            msg: 'sdsd',
            sub_id: ''
        },
        created: function () {
            console.log(this.menus);
        },
        methods: {
            selectAll: function (index){
                var val = this.menus[index].menu.all;
                for(var i=0;i<this.menus[index].submenu.length;i++) {
                    this.menus[index].submenu[i].checked = val;
                }
            },
            hasChild: function (index){
                for(var i=0;i<this.menus[index].submenu.length;i++) {
                    if(this.menus[index].submenu[i].checked){
                        return true;
                    }
                }
                return false;
            },
            pageList: function (index) {
                var list  = [];
                for(var i=0;i<this.menus[index].submenu.length;i++) {
                    if(this.menus[index].submenu[i].level!=4){
                        list.push(this.menus[index].submenu[i]);
                    }
                }
                return list;
            },
            actionList: function (index) {
                var list  = [];
                for(var i=0;i<this.menus[index].submenu.length;i++) {
                    if(this.menus[index].submenu[i].level==4){
                        list.push(this.menus[index].submenu[i]);
                    }
                }
                return list;
            }
         }
    })
</script>
		</div>
	</div>
<!--gonggao-->
<div class="footer">&copy; <?php echo date("Y");?> <?php echo C("SITE_NAME");?> , Inc. All rights reserved.</div>
<a href="#" id="j-gotop" class="gotop" title="回到顶部" style="right:45px; display: inline;"></a>
<script type="text/javascript">
$(function(){
    var height1=$(".content-right").height();
    var height2=$(".content-left").height();
    if(parseInt(height1) < parseInt(height2)){
        $(".content-right").css({'min-height': height2});
    }
    $(window).scroll(function() {
		$(this).scrollTop() >= 150 ? $("#j-gotop").fadeIn(300) : $("#j-gotop").fadeOut(300)
	});
});
</script>
</body>
</html>